import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
// 导入字体图标样式
import './assets/fonts/iconfont.css'
// 导入全局样式
import './assets/css/global.css'
//需要下载运行依赖
import TreeTable from 'vue-table-with-tree-grid'
//导入富文本编辑器插件
import VueQuillEditor from 'vue-quill-editor'
//富文本编辑器需要的css样式
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme

//导入axios
import axios from 'axios'
axios.defaults.baseURL = "http://127.0.0.1:8888/api/private/v1/"
//请求拦截器
axios.interceptors.request.use(config=>{
  config.headers.Authorization = window.sessionStorage.getItem('token')
  //这个必须要加
  return config
})

Vue.component('tree-table',TreeTable);
Vue.filter('dateFormat',function(originval){
  var dt = new Date(originval)

  var y = dt.getFullYear()
  var m = (dt.getMonth()+1 + '').padStart(2,'0')
  var d = (dt.getDate() + '').padStart(2,'0')

  var hh = (dt.getHours() + '').padStart(2,'0')
  var mm = (dt.getMinutes() + '').padStart(2,'0')
  var ss = (dt.getSeconds() + '').padStart(2,'0')
  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})

Vue.prototype.$http = axios



Vue.config.productionTip = false
//全局注册，富文本编辑器组件
Vue.use(VueQuillEditor, /* { default global options } */)
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
